home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / textfile.swg / 0026_Text to COM File.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-11-02  |  4.0 KB  |  115 lines

  1. {
  2. FRED JOHNSON
  3.  
  4. > Can anyone shed some light on creating a front-end loader for a Pascal .EXE
  5. > file?
  6.  
  7. {
  8.  *** Here is a piece of code that expresses the basic concept for which
  9.  *** you are looking.  It takes a text file (.msg) you supply and performs
  10.  *** an extremely simple encription on it and attaches a display method
  11.  *** and a password you supply.  It then makes a .COM file that displays
  12.  *** the file contents once you enter the correct password.
  13.  *** The code is very inefficient, but written that way to show the method
  14.  *** used to write the ASM code to the file. A better way to do this would
  15.  *** be to place your standard ASM code in an array and increment a
  16.  *** pointer to each command as you write it to the disk.  Let me know if
  17.  *** you want to see a rewrite.
  18. }
  19. Uses
  20.   DOS,
  21.   CRT;
  22.  
  23. VAR
  24.   FName,
  25.   RName    : File Of Byte;
  26.   B, Q     : Byte;
  27.   Password : String[10];
  28.   I_name   : String[12];
  29.   J        : Integer;
  30.  
  31. PROCEDURE Z;
  32. Begin
  33.   Write(FName, Q);
  34. End;
  35.  
  36. Begin
  37.   ClrScr;
  38.   Write('Input file name (extension must be .msg) : ');
  39.   Readln(I_name);
  40.   Assign(FName, I_name + '.com');
  41.   Assign(RName, I_name + '.msg');
  42.   ReWrite(FName);
  43.   Reset(RName);
  44.   Write('What is the Password you wish to use? 1 - 9 characters :');
  45.   Readln(Password);
  46.   B := Length(Password);
  47.   J := 1;
  48. {***********************************************************************}
  49.   Q := $b4; Z; Q := $0a; Z;              { MOV    AH,0A   }
  50.   Q := $ba; Z; Q := $4b; Z; Q := $01; Z; { MOV    DX,014B }
  51.   Q := $cd; Z; Q := $21; Z;              { INT    21      }
  52.   Q := $BE; Z; Q := $4D; Z; Q := $01; Z; { MOV    SI,014D }
  53.   Q := $8A; Z; Q := $04; Z;              { MOV    AL,[SI] }
  54.   Q := $3C; Z; Q := $24; Z;              { CMP    AL,24   }
  55.   Q := $74; Z; Q := $07; Z;              { JZ     0117    }
  56.   Q := $04; Z; Q := $08; Z;              { ADD    AL,08   }
  57.   Q := $88; Z; Q := $04; Z;              { MOV    [SI],AL }
  58.   Q := $46; Z;                           { INC    SI      }
  59.   Q := $EB; Z; Q := $F3; Z;              { JMP    010A    }
  60.   Q := $B8; Z; Q := $03; Z; Q := $00; Z; { MOV    AX,0003 }
  61.   Q := $CD; Z; Q := $10; Z;              { INT    10      }
  62.   Q := $B9; Z; Q := B;   Z; Q := $00; Z; { MOV    CX,length of Password }
  63.   Q := $BE; Z; Q := $4d; Z; Q := $01; Z; { MOV    SI,014c }
  64.   Q := $BF; Z; Q := $57; Z; Q := $01; Z; { MOV    DI,0148 }
  65.   Q := $F3; Z;                           { REPZ           }
  66.   Q := $A6; Z;                           { CMPSB          }
  67.   Q := $75; Z; Q := $1b; Z;              { JNZ    014a    }
  68.   Q := $BE; Z; Q := $61; Z; Q := $01; Z; { MOV    SI,0161 }{message start}
  69.   Q := $8A; Z; Q := $04; Z;              { MOV    AL,[SI] }
  70.   Q := $3C; Z; Q := $24; Z;              { CMP    AL,24   }
  71.   Q := $74; Z; Q := $07; Z;              { JZ     013a    }
  72.   Q := $34; Z; Q := $02; Z;              { XOR    AL,02   }
  73.   Q := $88; Z; Q := $04; Z;              { MOV    [SI],AL }
  74.   Q := $46; Z;                           { INC    SI      }
  75.   Q := $EB; Z; Q := $F3; Z;              { JMP    012d    }
  76.   Q := $B4; Z; Q := $09; Z;              { MOV    AH,09   }
  77.   Q := $BA; Z; Q := $61; Z; Q := $01; Z; { MOV    DX,0161 }{message start}
  78.   Q := $CD; Z; Q := $21; Z;              { INT    21      }
  79.   Q := $31; Z; Q := $C0; Z;              { XOR    AX,AX   }
  80.   Q := $CD; Z; Q := $16; Z;              { INT    16      }
  81.   Q := $B8; Z; Q := $03; Z; Q := $00; Z; { MOV    AX,0003 }
  82.   Q := $CD; Z; Q := $10; Z;              { INT    10      }
  83.   Q := $CD; Z; Q := $20; Z;              { INT    20      }
  84. {************************************************************************}
  85.   Q := B + 1;
  86.   Z;
  87.   Q := $24;
  88.   For B := 1 to 11 do
  89.     Z;
  90.   For B := 1 to Length(Password) Do
  91.   Begin
  92.     Q := Ord(Password[B]) + 8;
  93.     Z;
  94.   End;
  95.   While Length(Password) < 10 Do
  96.   Begin
  97.     Password := Password + '$';
  98.     Z;
  99.   End;
  100.   While Not EOF(RName) Do
  101.   Begin
  102.     Read(RName, B);
  103.     If B <> 26 Then
  104.     Begin
  105.       Q := B XOr 2;
  106.       Z;
  107.       Inc(J);
  108.     End;
  109.   End;
  110.   Q := $24;
  111.   Z;
  112.   Close(RName);
  113.   Close(FName);
  114. End.
  115.